function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentDate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + " " + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds();
    return currentDate;
}

function getNowTime() {
    var date = new Date();
    var _symbol = ":"
    var nowTime = formatNumber(date.getHours()) + _symbol + formatNumber(date.getMinutes()) + _symbol + formatNumber(date.getSeconds())
    return nowTime;
}

function isEmpty(val) {
    if (val == undefined || val == null || val == '' || val == 'undefined') {
        return true;
    } else {
        return false;
    }
}

function formatTime(date) {
    var year = date.getFullYear()
    var month = date.getMonth() + 1
    var day = date.getDate()

    var hour = date.getHours()
    var minute = date.getMinutes()
    var second = date.getSeconds()

    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
    n = n.toString()
    return n[1] ? n : '0' + n
}

module.exports = {
    formatTime: formatTime,
    getNowFormatDate: getNowFormatDate,
    isEmpty: isEmpty,
    getNowTime: getNowTime
}
